#include<math.h>
//#include "qgaus.h"
double sphr,cylr,dcsphacyl,Voxel_size,Voxel_volume;
// sphr : the radius of   sphere
// cylr : the radius of   cylinder
// dcsphacyl : the distance from the center of the sphere to the axis of the cylinder
//---------------------------------------------------------------------------
template <class myType>
myType GetMax (myType a, myType b)
{
 return (a>b?a:b);
}

template <class myType>
myType GetMin (myType a, myType b)
{
 return (a<b?a:b);
}

//---------------------------------------------------------------------------
//allocate a 2D array
template <class T>
//T** allocate2D(int rows,int cols)
void allocate2D(T **arr2D,int rows,int cols)
{
//	T **arr2D;
	int i;

	arr2D = (T**)malloc(rows*sizeof(T*));
	for(i=0;i<rows;i++)
	{
		arr2D[i] = (T*)malloc(cols*sizeof(T));
	}
//return arr2D;
}

//deallocate a 2D array
template <class T>
void deallocate2D(T** arr2D,int rows)
{
	int i;

	for(i=0;i<rows;i++)
	{
		free(arr2D[i]);
	}
	free(arr2D);
}
//---------------------------------------------------------------------------
//allocate a 3D array
template <class T>
//T*** allocate3D(int l,int m,int n)
void allocate3D(T ***arr3D,int l,int m,int n)
{
//T ***arr3D;
int i,j,k;

arr3D = (T***)malloc(l * sizeof(T**));

for(i=0;i<l;i++)
{
		arr3D[i] = (T**)malloc(m * sizeof(T*));
		for(j=0;j<m;j++)
		{
				arr3D[i][j] = (T*)malloc(n*sizeof(T));
		}
}
//return arr3D;
}

//deallocate a 3D array
template <class T>
void deallocate3D(T ***arr3D,int l,int m)
{
    int i,j;

    for(i=0;i<l;i++)
    {
        for(int j=0;j<m;j++)
        {
                free(arr3D[i][j]);
        }
        free(arr3D[i]);
    }
    free(arr3D);
}
//---------------------------------------------------------------------------
